namespace mock_ehr_lib.Data.LookupServices
{
    public class FDBLookupService : ILookupService
    {
        private static FDBLookupService _instance;
        private FDBLookupService()
        {
            
        }
        public static FDBLookupService Instance
        {
            get { return _instance ?? (_instance = new FDBLookupService()); }
        }

        public string GetDescriptionByCode(string code)
        {
            var client = new DBManagerService();
            var ids = client.findRxcuiById("HIC_SEQN", code.Replace("-", ""));
            if (ids.Length > 0)
            {
                var conceptGroups = client.getAllRelatedInfo(ids[0]);
                if(conceptGroups.Length > 0)
                {
                    if(conceptGroups[0].rxConcept.Length > 0)
                    {
                        return conceptGroups[0].rxConcept[0].STR;
                    }
                }
            }
            return null;
        } 
    }
}